using System;
using System.IO;
using System.Xml;

namespace Altova.IO
{
	public class StreamInput : Input
	{
		private Stream stream;

		public override Stream Stream
		{
			get
			{
				return stream;
			}
		}

		public override TextReader Reader
		{
			get
			{
				throw new Exception("This is not a reader");
			}
		}

		public override XmlDocument Document
		{
			get
			{
				throw new Exception("This is not an XML Dom tree");
			}
		}

		public StreamInput(Stream s)
			: base(InputType.Stream)
		{
			stream = s;
		}

		public override void Close()
		{
			stream.Close();
		}

		public static StreamInput createInput(string url)
		{
			string text = url.Trim();
			if (text.IndexOf(':') > 1)
			{
				return new UrlInput(text);
			}
			return new FileInput(text);
		}
	}
}
